<?php
class CookieUtils
{
    /**
     * @param string $value
     */
    public static function SetUserNameCookie($value)
    {
        self::SetCookie("username", $value);
    }

    /**
     * @param bool $value
     */
    public static function SetLoginRequiredCookie($value)
    {
        self::SetCookie("loginreq", intval($value));
    }

    /**
     * @param int $value
     */
    public static function SetCartCountCookie($value)
    {
        self::SetCookieExpiresAtEndOfSession("cartcount", $value);
    }

    /**
     * @param string $name
     * @param mixed int or string $value
     */
    public static function SetCookie($name, $value)
    {
        $sessionLifeTime = ini_get("session.gc_maxlifetime");
        Response::SetCookie($name, $value, time() + $sessionLifeTime, false);
    }

    /**
     * Cookie will be removed at end of session
     *
     * @param $name
     * @param $value
     */
    public static function SetCookieExpiresAtEndOfSession($name, $value)
    {
        Response::SetCookie($name, $value, 0, false);
    }
}